$(function () {
    // 设置登录按钮点击事件
    $('.input_sub').on('click', function (e) {
        e.preventDefault();
        // 获取用户信息
        let username = $('.input_txt').val().trim();
        let password = $('.input_pass').val().trim();
        if (username == '' || password == '') return;
        // 发起ajax请求，接收数据
        $.ajax({
            type: 'post',
            url: BigNew.user_login,
            data: {
                username: username,
                password: password
            },
            success: function (backData) {
                if (backData.code == 200) {
                    // 登录时保存token
                    localStorage.setItem('token', backData.token);
                    $('#myModal').modal();
                    $('.modal-body p').text(backData.msg);
                    $('#myModal').on('hidden.bs.modal', function (e) {
                        window.location = './index.html';
                    })
                } else {
                    $('#myModal').modal();
                    $('.modal-body p').text(backData.msg);
                }
            }
        })
    })
})